# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-golang-x-tools
pkgver=0.0.20191225
_commit=7b8e75db28f4b09dc0b853eadee5b034956bcb9e
pkgrel=2
pkgdesc='Various packages and tools that support the Go programming language'
arch=('any')
url="https://github.com/golang/tools"
license=('BSD')
depends=('go' 'golang-golang-x-net')
source=("$pkgname-$_commit.tar.gz::https://github.com/golang/tools/archive/$_commit.tar.gz")
sha512sums=('c61e2ca18fe5243a5cf1e4d22d248894ca06fcdeda0fec4402f55d9cd517484e3587e8c82e88e5191a381c12247cf2dee824e29dea2963376526c41b4899a14f')

check() {
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/golang.org/x
  cp -a "$srcdir"/tools-$_commit "$srcdir"/build/src/golang.org/x/tools
  cd "$srcdir"/build/src/golang.org/x/tools
  go test -v $(go list ./...) || :
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/golang.org/x
  cp -a "$srcdir"/tools-$_commit "$pkgdir"/usr/share/gocode/src/golang.org/x/tools

  install -Dm644 tools-$_commit/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
